window.onload = function() {
	seajs.use(['jquery-1.8.2.js', 'iscroll_module.js', 'mdialog_module.js', 'util_module.js', 'imgUpload_module.js', ], function(Z, I, M, U, IMG) {
		var user = U.checkLogin();
		var user_typ=U.getParam('typ');
		U.fillHead();
		U.fillTree();
		U.fillFooter();

		initPage();
		function initPage() { //初始化页面
			var params = {
				userId: user.info.id, //1(1-默认排序,2-时间排序)
				state:-2
			};
			U.loadOpt(false);
			U.ajax("/project/list", params, function(json) {
				if(json.success) {
					$(json.models.projectList).each(function() {
						var p_state = "项目未开展";
						if(this.state == 2 || this.state == 3) {
							p_state = "项目进行中";
						}
						if(this.state == 4) {
							p_state = "项目已完成";
						}
						var p_img = U.loadfail;
						if(U.getImg(this.images).length > 0) {
							p_img = U.getImg(this.images)[0];
						}
						var p = "<div id='" + this.id + "' ><div class='p_name'>" + this.name + "</div><div class='subtitle'>" + this.title + "</div><div class='p_img'><img src='" + p_img + "'></div><div class='help_info'>【扶贫信息】</div><div class='help_name'>" + this.povertyName + "</div><div class='money'></div><div class='p_state'>" + p_state + "</div></div>";
						$(".poor_list").append(p);
					});
					$(".poor_list>div").unbind("click").click(function() {
						window.open("project_details.html?id=" + $(this).attr("id"));
					})

					U.loadOpt(false);
				} else {
					M.toast(false, json.errorMsg);
				}
			});
		}

	});
}